﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Corsat.Web
{
    public partial class AdminInsertItems : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnPrepareItems_Click(object sender, EventArgs e)
        {
            DataTable dtItems = new DataTable();
            dtItems.Columns.Add("ItemName");

            for (int i = 0; i < Convert.ToInt32(txtNumberOfChurchs.Text); i++)
                dtItems.Rows.Add(dtItems.NewRow());

            gvItems.DataSource = dtItems;
            gvItems.DataBind();

        }

        protected void btnCreateItems_Click(object sender, EventArgs e)
        {
            List<string> Items = new List<string>();

            for (int i = 0; i < Convert.ToInt32(txtNumberOfChurchs.Text); i++)
            {
                string item = (gvItems.Rows[i].FindControl("txtItem") as TextBox).Text;
                Items.Add(item);
            }

            Corsat.Library.DataManager.Main.AddParentAndChildrenItems(txtDiocese.Text, Library.DataManager.Category.Dioceses, Items, Library.DataManager.Category.Churchs);

        }
    }
}